/*
* $Id: FamilyManager.h 156 2010-09-28 19:00:52Z volok-aleksej@yandex.ru $
*
* Copyright 2010 by Volokitin Alexey
* All rights reserved
*
*/
#ifndef _FAMILY_MANAGER_H_
#define _FAMILY_MANAGER_H_

#include "JournalInterface.h"

class CFamilyManager
{
public:
	struct point{
		std::tstring m_strName;
		int m_nIdRecord;
		std::tstring m_strNote;
		point();
		point(const point& pnt);
		void operator = (const point& pnt);
	};
	struct family{
		std::tstring m_strName;
		int m_nIdPoint;
		std::tstring m_strNote;
		Family::type m_type;
		int m_nIdRecord;
		family();
		family(const family& fml);
		void operator = (const family& fml);
	};
protected:
	std::map<int, point> m_aPoints;
	std::map<int, family> m_aFamily;
	std::map<int, std::vector<int> > m_aPntFamily;
protected:
	void Rename(int nId, int type, const std::tstring& strNewName);
	void DelFamily(int nId, IDatabase* pDb);
public:
	CFamilyManager();
	~CFamilyManager();
public:
	void Init();
	std::map<int, point> GetPoints();
	point GetPoint(int nId);
	std::map<int, family> GetFamilies();
	std::map<int, family> GetFamilies(int nIdPoint);
	family GetFamily(int nIdFamily);
	int AddFamily(family fml, const std::map<std::tstring, std::tstring>& aUserFields);
	void AddPoint(point pnt, const std::map<std::tstring, std::tstring>& aUserFields);
	void ChangeFamily(int nId, family fml, const std::map<std::tstring, std::tstring>& aUserFields);
	void ChangePoint(int nId, point pnt, const std::map<std::tstring, std::tstring>& aUserFields);
	void RenameFamily(int nId, const std::tstring& strNewName);
	void RenamePoint(int nId, const std::tstring& strNewName);
	void DeletePoint(int nId);
	void DeleteFamily(int nId);
};

#endif/*_FAMILY_MANAGER_H_*/